//
//  BaseTableViewCell.m
//  待定
//
//  Created by BoyaLee on 15/11/6.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "BaseTableViewCell.h"

@implementation BaseTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
#warning 注册通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"changeColor" object:nil];
        
        if ([[NSUserDefaults standardUserDefaults] boolForKey:@"night"])
        {
            self.backgroundColor = BGNIGHTMODEL;
        }
        else
        {
            self.backgroundColor = BGDAYMODEL;
        }
    }
    return self;
}


-(void)changeColor:(NSNotification *)notification
{
    
    NSString *str = [notification object];
    if ([str isEqualToString:@"no"]) {
        self.backgroundColor = BGDAYMODEL;
    }
    else
    {
        self.backgroundColor = BGNIGHTMODEL;
    }
    //保存当前状态值
    //[[NSUserDefaults standardUserDefaults] setObject:str forKey:@"night"];
    
}


@end
